#pragma once
#include <iostream>
#include <algorithm>
#include "DataType.h"
#include <string>
#include <sstream>
#include <iomanip>
//#include <numeric>

namespace container_test
{
    void test_1()
    {
        std::vector<size_t> array{1,2,4,6,9};

        auto iter = std::find(array.begin(), array.end(), 4);
        auto iter1 = std::find(array.begin(), array.end(), 3);
        auto iter2 = std::find(array.begin(), array.end(), 8);
        
    }

    void test_2()
    {
        Line2D line{ Point2D{12,13},Point2D{13,98} };

        Line2D::iterator temp;
        auto iter = std::find(line.begin(), line.end(), Point2D{ 12,13 });
        auto iter1 = std::find(line.begin(), line.end(), Point2D{ 13,98 });
        auto iter2 = std::find(line.begin(), line.end(), Point2D{ 13,8 });
        
        if (iter2 == std::end(line))
        {
            int ll = 111;
        }
    }

    void test_3()
    {
        std::vector<size_t> array1{ 2,2,3,4,6 };
        std::vector<size_t> array2{ 2,2,3,4,6 };
        std::vector<size_t> array3{ 2,2,3,4,4 };
        std::vector<size_t> array4;
        array4.emplace_back(2);
        array4.emplace_back(3);
        array4.emplace_back(2);
        array4.emplace_back(4);
        array4.emplace_back(6);
        bool flag = array1 == array2;
        flag = array2 == array3;
        flag = array1 == array3;
        flag = array2 == array4;
    }
    void test_4()
    {
        std::vector<size_t> array;
        array.reserve(20);
        for (size_t i = 0 ; i < 10 ; i++)
        {
            array.emplace_back(i);
        }
    }
    void test_5()
    {
        std::vector<size_t> array{ 1,2,4,5,6 };
        array.reserve(20);
        for (size_t i = 0; i < 10; i++)
        {
            array.emplace_back(i);
        }
    }


    void test_6()
    {
        std::string value = "    sda sda hl dh sl as h  ";
        //auto index= std::remove_if(value.begin(), value.end(), std::isspace);
        //char space = ' ';
        //auto index = std::remove_if(value.begin(), value.end(), [](char c) {return c == space; });
        //size_t i = std::distance(value.begin(), index);
        //value = value.substr(0, std::distance(value.begin(), index));

        //index = std::remove_if(value.begin(), value.end(), std::isspace);
        //value = std::string{};
        value = "12313.43253003";
        auto result= std::stod(value);
        value = "3123 .332 3";
        result = std::stod(value);
    }

    void test_7()
    {
        double value = 8.00121321;
        double result = static_cast<double>(static_cast<int>(value));
        value++;
    }

    double switchingAccuracy(double value, size_t precision)
    {
        std::ostringstream stream;
        stream << std::fixed << std::setprecision(precision) << value;
        std::string strValue = stream.str();
        return std::stod(strValue);
    }
    void findKeyEle()
    {
        std::vector<double> versines{ 3,5,7,11,20,13,11,9,5,1,0,-1,-2,-4,-7,-11,-11,-10,-8,-5,-4,-2,0,3 };

        size_t startIndex = 10;//inqury::getIndex(stationings, curRange.start, true);
        size_t endIndex = 22;
        auto iterMax = std::max_element(versines.cbegin() + startIndex, versines.cbegin() + endIndex);
        auto iterMin = std::min_element(versines.cbegin() + startIndex, versines.cbegin() + endIndex);

        bool isPositive = std::abs(*iterMax) > std::abs(*iterMin);
    }

    void insertTest()
    {
        std::vector<double> list{0,1,3,4,5,6,7,8};
        list.insert(list.begin() + list.size(), 99);
        list.insert(list.begin() + 2, 200);
        list.insert(list.end(), 900);

        std::vector<std::string> listStrings;
        std::string vStr = "sss";
        listStrings.insert(listStrings.begin(), vStr);

    }
    void reseverSize()
    {
        std::vector<double> list1{0,2,3,7};
        list1.reserve(list1.size() + 3);
        list1.emplace_back(77.1);
        list1.emplace_back(9.1);
        list1.emplace_back(12.1);
        list1.emplace_back(15.1);
    }
    void removeEle()
    {
        std::vector<double> list1{ 0,2,3,7 };
        list1.erase(list1.end() - 1);
    }
}